Skip to content

Conversation

@Zapper9982
Copy link
Contributor

@Zapper9982 Zapper9982 commented Jul 8, 2025

📋 Description

This pull request updates the GitHub Actions workflow, TestCase Coverage Check, designed to automate the validation of test cases and code coverage.

The primary motivation behind this change is to ensure that all pull requests maintain or improve code quality by:

  1. Automatically running all unit tests and failing the build if any tests do not pass.

  2. Generating a JaCoCo code coverage report.

  3. Comparing the code coverage of the pull request's branch against the base branch (e.g., master or develop).

  4. Posting a comment on the pull request with a detailed breakdown of coverage changes, providing immediate feedback to developers.

This workflow addresses a previous HttpError: Resource not accessible by integration issue encountered when posting coverage comments on organization repositories, especially for pull requests originating from forked repositories. The new two-job structure (build-and-test-pr and post-coverage-comment) leverages pull_request_target securely to grant the necessary write permissions for commenting, while maintaining a secure execution environment for untrusted code from forks.


✅ Type of Change

  • 🐞 Bug fix (non-breaking change which resolves an issue)

  • New feature (non-breaking change which adds functionality)

  • 🔥 Breaking change (fix or feature that would cause existing functionality to not work as expected)

  • 🛠 Refactor (change that is neither a fix nor a new feature)

  • ⚙️ Config change (configuration file or build script updates)

  • 📚 Documentation (updates to docs or readme)

  • 🧪 Tests (adding new or updating existing tests)

  • 🎨 UI/UX (changes that affect the user interface)

  • 🚀 Performance (improves performance)

  • 🧹 Chore (miscellaneous changes that don't modify src or test files)


ℹ️ Additional Information

Summary by CodeRabbit

  • Chores
    • Improved test coverage workflow for pull requests, including enhanced reporting and automated coverage comments on PRs.

@coderabbitai
Copy link

coderabbitai bot commented Jul 8, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The workflow configuration for test coverage was updated to trigger on both pull request and pull request target events for specific branches. The build job was renamed and restricted to run only on pull_request events with adjusted permissions. The checkout step now explicitly checks out the PR head commit. A new job was added to post JaCoCo coverage comments on pull requests after downloading the coverage artifact, running only on pull_request_target events with appropriate permissions.

Changes

File(s) Change Summary
.github/workflows/testcase-coverage.yml Updated workflow triggers; renamed and restricted build job; clarified checkout and Maven steps; added new post-coverage-comment job with artifact download and coverage comment posting.

Sequence Diagram(s)

sequenceDiagram
    participant GitHub Actions
    participant build-and-test-pr
    participant post-coverage-comment

    GitHub Actions->>build-and-test-pr: Trigger on pull_request (master/develop)
    build-and-test-pr->>build-and-test-pr: Checkout PR head commit
    build-and-test-pr->>build-and-test-pr: Run Maven tests
    build-and-test-pr->>build-and-test-pr: Upload JaCoCo report artifact
    build-and-test-pr-->>post-coverage-comment: Trigger on pull_request_target after success
    post-coverage-comment->>post-coverage-comment: Checkout base branch
    post-coverage-comment->>post-coverage-comment: Download JaCoCo artifact
    post-coverage-comment->>post-coverage-comment: Run coverage comparison and post comment
Loading

Poem

A workflow hops with nimble feet,
From build to tests, it can’t be beat.
Now coverage comments join the show,
On every PR, the numbers grow.
With artifacts and tokens in tow,
This rabbit’s CI garden’s aglow!
🐇✨

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
.github/workflows/testcase-coverage.yml (3)

13-17: Tighten global permissions – issues: write is unused

The workflow never creates/edits issues, yet grants that permission.
Remove it to follow the principle of least privilege.

 permissions:
   contents: read
   pull-requests: write
-  issues: write

37-40: Cache Maven deps & run in batch mode for a 50-70 % speed-up

-      - name: Build with Maven and Run Tests
-        run: |
-          mvn clean verify -Dmaven.test.failure.ignore=false
+      - name: Cache & Build with Maven (tests)
+        uses: actions/setup-java@v4
+        with:
+          java-version: '17'
+          distribution: 'temurin'
+      - uses: actions/cache@v4
+        with:
+          path: ~/.m2/repository
+          key: maven-${{ hashFiles('**/pom.xml') }}
+          restore-keys: maven-
+      - run: mvn -B clean verify

Cuts cold-start latency and keeps logs terser with -B.


41-46: Minor path mismatch – upload single file, download into dir

You upload only jacoco.xml but download into target/site/jacoco/.
Safer to keep semantics aligned to avoid empty directory surprises:

-      path: target/site/jacoco/jacoco.xml
+      path: target/site/jacoco/

(or adjust the download path accordingly).

Also applies to: 62-67

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c21c3f8 and 29d9973.

📒 Files selected for processing (1)
  • .github/workflows/testcase-coverage.yml (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (java)
🔇 Additional comments (1)
.github/workflows/testcase-coverage.yml (1)

68-74: Verify coverage diff accuracy – job runs on base commit but passes PR coverage

Because the step checks out the base branch then feeds it the PR’s coverage file, madrapps/jacoco-report may compute deltas against itself, not the true head-vs-base diff.
Please confirm the action’s behaviour or swap the order:

  1. Download artifact
  2. Checkout PR head with clean: false

so the workspace code matches the report.

@Zapper9982 Zapper9982 marked this pull request as draft July 8, 2025 10:31
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jul 8, 2025

@Zapper9982 Zapper9982 marked this pull request as ready for review September 2, 2025 18:00
@Zapper9982
Copy link
Contributor Author

@drtechie @vanitha1822

This workflow is ready to merge , the jacoco report seems to be working now. will raise PR for the same on other API's as well

vanitha1822
vanitha1822 previously approved these changes Sep 3, 2025
@vanitha1822
Copy link
Member

@drtechie @vanitha1822

This workflow is ready to merge , the jacoco report seems to be working now. will raise PR for the same on other API's as well

@Zapper9982 Ensure the correct base branch for all the repos please.
cc: @drtechie

@Zapper9982
Copy link
Contributor Author

@drtechie @vanitha1822
This workflow is ready to merge , the jacoco report seems to be working now. will raise PR for the same on other API's as well

@Zapper9982 Ensure the correct base branch for all the repos please. cc: @drtechie

I didnt quite catch it , are u telling for the workflow or are u asking me to change the branch on which the Pr is put on ?

@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 3, 2025

@vanitha1822
Copy link
Member

@drtechie @vanitha1822
This workflow is ready to merge , the jacoco report seems to be working now. will raise PR for the same on other API's as well

@Zapper9982 Ensure the correct base branch for all the repos please. cc: @drtechie

I didnt quite catch it , are u telling for the workflow or are u asking me to change the branch on which the Pr is put on ?

@Zapper9982 branch - in which you put your PR's. Because. I found in some repo's you are pointing to release-3.4.0. But here you are pointing to develop.

@Zapper9982
Copy link
Contributor Author

@drtechie @vanitha1822
This workflow is ready to merge , the jacoco report seems to be working now. will raise PR for the same on other API's as well

@Zapper9982 Ensure the correct base branch for all the repos please. cc: @drtechie

I didnt quite catch it , are u telling for the workflow or are u asking me to change the branch on which the Pr is put on ?

@Zapper9982 branch - in which you put your PR's. Because. I found in some repo's you are pointing to release-3.4.0. But here you are pointing to develop.

for Beneficiary API I have added on develop since there are no active changes , however other repos were evolving so I was asked to put a pr on 3.4.0

@drtechie drtechie changed the base branch from develop to main October 9, 2025 07:53
@drtechie drtechie merged commit b7badb1 into PSMRI:main Oct 9, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants